import org.junit.Test;
import static org.junit.Assert.*;
import java.util.Arrays;
import java.util.List;

public class PaperSelectionTest {
    @Test
    public void testSelectPaper() {
        PaperList list0fRainy = new PaperList("Rainy", Arrays.asList(
                new Thesis("Reading"),
                new ConferencePaper("Science"),
                new JournalPaper("Technology"),
                new JournalPaper("Art")
        ));

        // 测试用例1：选择1篇学位论文
        Student student1 = new Student("Cloudy1", 1, PaperType.Thesis);
        try {
            List<Paper> papers1 = list0fRainy.selectPaper(student1);
            assertEquals(1, papers1.size());
            assertTrue(papers1.get(0) instanceof Thesis);
        } catch (NoEnoughPapersException e) {
            fail("不应抛出异常");
        }

        // 测试用例2：选择2篇期刊论文
        Student student2 = new Student("Cloudy2", 2, PaperType.JournalPaper);
        try {
            List<Paper> papers2 = list0fRainy.selectPaper(student2);
            assertEquals(2, papers2.size());
            papers2.forEach(p -> assertTrue(p instanceof JournalPaper));
        } catch (NoEnoughPapersException e) {
            fail("不应抛出异常");
        }

        // 测试用例3：选择数量超过可用（预期异常）
        Student student3 = new Student("Cloudy3", 3, PaperType.Any);
        try {
            list0fRainy.selectPaper(student3);
            fail("应抛出NoEnoughPapersException");
        } catch (NoEnoughPapersException e) {
            assertTrue(e.getMessage().contains("希望选论文 3 篇"));
        }
    }
}